package pr.iceworld.fernando.gatecommon.web.result;

import java.io.Serializable;

/**
* Created by ferna on 2018/6/12.
*/
public class WebBaseResult<T> implements Serializable {
    public static final int STATUS_SUCCESS = 200;//成功
    public static final int STATUS_FAIL = 500;//失败
    public static final int STATUS_LOGIN_USER_NOT_EXIST = 5001;//登录用户不存在
    public static final int STATUS_LOGIN_USER_PASSWORD_ERROR = 5002;//登录密码错误
    public static final int STATUS_REGIST_USERNAME_EXIST = 5010;//注册用户已存在

    protected int status;
    protected String msg;
    protected T data;

    public WebBaseResult() {
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public WebBaseResult success() {
        this.setStatus(STATUS_SUCCESS);
        return this;
    }

    public WebBaseResult msg(String msg) {
        this.setMsg(msg);
        return this;
    }

    public WebBaseResult failure() {
        this.setStatus(STATUS_FAIL);
        return this;
    }

    public WebBaseResult data(T data) {
        this.setData(data);
        return this;
    }
}
